home *** CD-ROM | disk | FTP | other *** search
- Path: news.princeton.edu!blume
- From: blume@zayin.cs.princeton.edu (Matthias Blume)
- Newsgroups: comp.lang.c++
- Subject: Re: Is this a memory leak?
- Date: 05 Apr 1996 15:34:55 GMT
- Organization: Princeton University
- Distribution: world
- Message-ID: <BLUME.96Apr5103455@zayin.cs.princeton.edu>
- References: <4jv214$gv7@insosf1.netins.net> <4k02v5$tu7@grimsel.zurich.ibm.com>
- <4k2vku$s82@werple.net.au> <4k39f5$lhn@grimsel.zurich.ibm.com>
- NNTP-Posting-Host: zayin.cs.princeton.edu
- In-reply-to: wgk@zurich.ibm.com's message of 5 Apr 1996 14:07:33 GMT
-
- In article <4k39f5$lhn@grimsel.zurich.ibm.com> wgk@zurich.ibm.com (Keith Whittingham) writes:
-
- In <4k2vku$s82@werple.net.au>, davidw@werple.net.au (David White) writes:
- >wgk@zurich.ibm.com (Keith Whittingham) writes:
-
- >The use of 0 as a pointer is not the address 0x000. It is a null pointer
- >as defined by the language. Implementations are not even required to use a
- >bit pattern of all zeroes as a null pointer. They can use any value they
- >like, as long as it will not also be used as a real address. Furthermore,
- >rather than being a quirk of implementation, the language guarantees that
- >deleting a null pointer will do nothing.
- >
-
- Er, I don't think I agree.
-
- The line of code (if I remember correctly) was:
-
- bury = 0;
-
- 'bury' being a pointer to some element. bury *is* a pointer and it is
- assigned the value 0. 0 is the same as 0x0000. The line of code:
-
- bury = NULL;
-
- may of course set bury to some other value.
-
- May I suggest that you are greatly mistaken. NULL is the same as 0,
- and when used in a pointer context neither of them need to correspond
- to the bit-pattern where all bits are zero.
-
- If, for some compiler, a NULL pointer was implemented as a bit pattern
- of all ones then we could expect the code:
-
- bury = 0;
- delete bury;
-
- to have some very strange behaviour. Whereas
-
- bury = NULL;
- delete bury;
-
- would be 'safe' although undesireable.
-
- No, both would work and both would give the same result.
-
- --
- -Matthias
-